package com.gwd.task.repository;

import com.gwd.task.entity.CodeRepositoryEntity;
import com.gwd.task.model.transfer.ProjectGroupInterface;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 * @author zhiyongming
 * @date 2020/12/22 14:30
 */
@Repository
public interface CodeRepositoryRepository extends JpaRepository<CodeRepositoryEntity, Long>, JpaSpecificationExecutor<CodeRepositoryEntity> {
    @Query(value = "SELECT GROUP_CONCAT(project_info.project_name) as members, code_repos_relate.cr_id as crId " +
                    "FROM code_repos_relate, project_info " +
                    "WHERE project_info.project_id=code_repos_relate.project_id GROUP BY code_repos_relate.cr_id", nativeQuery = true)
    List<ProjectGroupInterface> findByGroupList();

}
